package com.wnxy.service;

import com.wnxy.exception.LoginException;
import com.wnxy.util.GetRequestUtil;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.springframework.stereotype.Service;

import javax.servlet.http.HttpSession;

@Aspect
@Service
public class LoginValidateService {

    @Before("@annotation(com.wnxy.annotation.Validate)")
    public void before() throws LoginException {
        HttpSession session = GetRequestUtil.getSession();
        Object longinTeacher = session.getAttribute("loginManager");
        if(null==longinTeacher){
            throw new LoginException(201,"请先登录");
        }
    }
}
